<?php

if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
require_once( "class_3d/CheckMode_3d.php" );
$gametype = intval(getvar("gametype"));
$chkGametype = chkGametype($gametype);
if ($chkGametype == 0)
{
    exit();
}
$chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
$chk->checkShow3dPage();
$show3D3S = $chk->show3D3S;
$Show5NFlag = $show3D3S == 2 || $show3D3S == 3 ? true : getShow35($gametype);
$showPg = $g_gametype_3d[$gametype]['pg'];
unset($chk);
$ui = new UI_3D(true);
$tpl = new Template2();
$conf = new Config();
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$chkNN = intval(getvar("chkNN"));
if (getvar("mod") == "1")
{
    $conf->set("calcbet_{$tbl}", "0");
    if ($show3D3S == 1)
    {
        $id = getvar("id");
        if ($id != "")
        {
            $id = intval($id);
            $fields = array ();
            $fields['calcbet'] = "0";
            db_update("lotto_{$tbl}", $fields, "id={$id}");
        }
    }
    $chkNN = true;
}
$showRateFlag = false;
if ($conf->get("calcbet_{$tbl}") == "1" && getvar("calc") == "")
{
    $ui->showErrorPage("{$tblName}颁奖过帐中，请稍後再使用本功能！");
    exit();
}
$_8hFlag = false;
if ($Show5NFlag)
{
    if ($g_gametype_3d[$gametype]['type'] == 4)
    {
        include_once( "class_sb/MyLotto_sb.php" );
        $MyLotto_3d = new MyLotto_sb($gametype);
        $tdN5 = "<td height=\"20\">一</td><td>二</td><td>三</td>";
        $colspanNum = 3;
        $colspanAdd = 0;
        $colspanAllTr = 17;
    }
	elseif ($gametype == 24)
    {
        include_once( "class_5h/MyLotto_5h.php" );
        $MyLotto_3d = new MyLotto_5h($gametype);
        $tdN5 = "<td height=\"20\">一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td><td>七</td><td>八</td><td>九</td><td>十</td>";
        $colspanNum = 10;
        $colspanAdd = 7;
        $colspanAllTr = 30;
    }
    else if ($g_gametype_3d[$gametype]['type'] == 3 && $gametype != 20)
    {
        include_once( "class_5h/MyLotto_5h.php" );
        $MyLotto_3d = new MyLotto_5h($gametype);
        $tdN5 = "<td height=\"20\">一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td><td>七</td><td>八</td>";
        $colspanNum = 8;
        $_8hFlag = true;
        $colspanAdd = 5;
        $colspanAllTr = 21;
    }
    else if ($gametype == 20)
    {
        include_once( "class_5h/MyLotto_5h.php" );
        $MyLotto_3d = new MyLotto_5h($gametype);
        $tdN5 = "<td height=\"20\">一</td><td>二</td><td>三</td><td>四</td><td>特</td>";
        $colspanNum = 5;
        $colspanAdd = 2;
        $colspanAllTr = 20;
    }
    else
    {
        include_once( "class_3d/MyLotto_3d.php" );
        $MyLotto_3d = new MyLotto_3d_5n($gametype);
        $tdN5 = "<td height=\"20\">第一球</td><td>第二球</td><td>第三球</td><td>第四球</td><td>第五球</td>";
        $colspanNum = 5;
        $colspanAdd = 2;
        $colspanAllTr = 20;
    }
    $nClrArr = array (0 => array ("", "", "", "", ""), 1 => array ("", "", "", "", ""), 2 => array ("", "", "", "", ""), 10 => array ("", "", "", "", ""), 11 => array ("3", "3", "3", "2", "2"), 12 => array ("3", "3", "3", "2", "2"), 13 => array ("3", "3", "3", "2", "2"), 14 => array ("3", "3", "3", "2", "2"), 15 => array ("3", "3", "3", "2", "2"), 20 => array ("3", "2", "2", "2", "2"), 21 => array ("2", "2", "2", "2", "2", "2", "2", "2"), 22 => array ("2", "2", "2", "2", "2", "2", "2", "2"), 23 => array ("2", "2", "2", "2", "2", "2", "2", "2"), 30 => array ("2", "2", "2", "2", "2", "2", "2", "2", "2", "2"));
}
else
{
    include_once( "class_3d/MyLotto_3d.php" );
    $MyLotto_3d = new MyLotto_3d($gametype);
    $colspanNum = 3;
    $colspanAdd = 0;
    $colspanAllTr = 17;
    $tdN5 = "<td height=\"20\">第一球</td><td>第二球</td><td>第三球</td>";
    $nClrArr = array (0 => array ("", "", "", "", ""), 1 => array ("", "", "", "", ""), 2 => array ("", "", "", "", ""), 10 => array ("", "", "", "", ""), 11 => array ("", "", "", "", ""), 12 => array ("", "", "", "", ""), 13 => array ("", "", "", "", ""), 14 => array ("", "", "", "", ""), 15 => array ("", "", "", "", ""), 20 => array ("3", "2", "2", "2", "2"));
}
$page = getvar("page");
$page = $page == "" ? 1 : intval($page);
if ($curruser['acl'] == 255 && ( $curruser['prev_id'] == 0 || SubAccountRight($curruser, 3) == 2 ))
{
    $showRateFlag = true;
}
$mytd2 = "";
$showRound = false;

switch ($show3D3S)
{
    case 0 :
        $lotto3dphp = "lotto_3d";
        $rs = $MyLotto_3d->getDataList($page, 15);
        $showOpenTime = false;
        $width = "860";
        $colspan = 6 + $colspanAdd;
        $editpapadate = "";
        break;
    case 1 :
    case 2 :
        $lotto3dphp = "lotto_3s";
        $rs = $MyLotto_3d->getDataList3s($page, 15);
        $showOpenTime = true;
        if ($_8hFlag)
        {
            $width = "980";
        }
        else
        {
            $width = "900";
        }
        $colspan = 7 + $colspanAdd;
        $editpapadate = "<a href=\"op.php?op=admin&fp=chgPaperDate_3d&gametype={$gametype}\">报表日期异动</a>&nbsp;|&nbsp;";
        break;
    case 3 :
        $lotto3dphp = "lotto_3s";
        $rs = $MyLotto_3d->getDataList3s($page, 15);
        $showOpenTime = true;
        if ($_8hFlag)
        {
            $width = "980";
        }
        else
        {
            $width = "900";
        }
        $colspan = 7 + $colspanAdd;
        $editpapadate = "<a href=\"op.php?op=admin&fp=chgPaperDate_3d&gametype={$gametype}\">报表日期异动</a>&nbsp;|&nbsp;";
        break;
}
$getOpenUrl = $MyLotto_3d->getOpenUrl($gametype);
if ($chkNN && $getOpenUrl != "" && $page == 1)
{
    $colspan = 8 + $colspanAdd;
    $width = "980";
    $mytd2 = "<td rowspan='2'>&nbsp;</td>";
    $historyGetNum_3d = "historyGetNum_3d.htm";
    $tpl->load("historyGetNum_3d", $historyGetNum_3d);
    $tpl->set(array ("getOpenUrl" => $getOpenUrl, "getOpenUrlPage" => 15, "mytd2" => "", "BNLeng" => $MyLotto_3d->getBNLeng($gametype), "gametype" => $gametype, "chkOpenJS" => $Show5NFlag ? "" : ".slice(-5)"));
    $showRound = true;
}
if ($page == 1)
{
    $lottoMsg = "";
    if (2 < $gametype && intval($conf->get("lotto_auto_{$tbl}")))
    {
        $lottoMsg = "<tr class='td2' ><td colspan='{$colspanAllTr}' align='right' style='font-size:13px;'>" . $conf->get("lotto_auto{$tbl}Msg") . "</td></tr>";
    }
    $tpl->set("mytr02", $lottoMsg . "<tr class='bgClc_{$gametype}'></tr>");
}
$totalamount = 0;
$totalmb = 0;
$totalad = 0;
$totalua = 0;
$totalur = 0;
$totalrsum = 0;
$today = date("Y-m-d");
$postTime = $conf->get("paper_post_bet");
$today2 = date("Hi") <= $postTime ? date("Y-m-d", strtotime("-1 day")) : date("Y-m-d");
$stateArr = array ("<font color=\"red\">未颁奖</font>", "<font color=\"red\">处理中</font>", "");
switch ($gametype)
{
    case 12 :
        if (date("Hi") < "0210")
        {
            $paperDay = date("Y-m-d", strtotime("-1 day"));
        }
        else
        {
            $paperDay = $today;
        }
        break;
    case 14 :
        if (date("Hi") < "0210")
        {
            $paperDay = date("Y-m-d", strtotime("-1 day"));
        }
        else
        {
            $paperDay = $today;
        }
        break;
    default :
        $paperDay = $today;
        break;
}
$paperShowOpen = getPaperMinDate(0 - 1);
$paperShowOpenInt = strtotime($paperShowOpen);
if ($rs->eof)
{
    $list = "<td colspan=30 class=td2 align=center>目前无{$tblName}相关期数资料</td>";
}
else
{
    $list = "<tbody id=\"tbdList\">";
    $supAmdFlag = $curruser['account'] == G_SUPERACCOUNT && $curruser['acl'] == 255;
    while (!$rs->eof)
    {
		if($gametype!=25 && $gametype!=26){
        	$n5 = $rs->f['n5'] == 0 - 1 ? "" : $rs->f['n5'];
        	$n4 = $rs->f['n4'] == 0 - 1 ? "" : $rs->f['n4'];
		}
        $n3 = $rs->f['n3'] == 0 - 1 ? "" : $rs->f['n3'];
        $n2 = $rs->f['n2'] == 0 - 1 ? "" : $rs->f['n2'];
        $n1 = $rs->f['n1'] == 0 - 1 ? "" : $rs->f['n1'];
        $chkN6 = 0 - 1;
        $chkN7 = 0 - 1;
        $chkN8 = 0 - 1;
        switch ($show3D3S)
        {
            case 0 :
                $classStr = $rs->f['open'] == $today ? "td6" : "td2";
                break;
            case 1 :
                $timeTemp = systime();
                $classStr = strtotime($rs->f['startbet']) < $timeTemp && $timeTemp < strtotime($rs->f['openbet']) ? "td6" : "td2";
                break;
            case 2 :
                if ($gametype == 24)
                {
                    $n1 = $rs->f['n10'] == 0 - 1 ? "" : $rs->f['n10'];
                    $n2 = $rs->f['n9'] == 0 - 1 ? "" : $rs->f['n9'];
                    $n3 = $rs->f['n8'] == 0 - 1 ? "" : $rs->f['n8'];
                    $n4 = $rs->f['n7'] == 0 - 1 ? "" : $rs->f['n7'];
                    $n5 = $rs->f['n6'] == 0 - 1 ? "" : $rs->f['n6'];
                    $n6 = $rs->f['n5'] == 0 - 1 ? "" : $rs->f['n5'];
                    $n7 = $rs->f['n4'] == 0 - 1 ? "" : $rs->f['n4'];
                    $n8 = $rs->f['n3'] == 0 - 1 ? "" : $rs->f['n3'];
                    $n9 = $rs->f['n2'] == 0 - 1 ? "" : $rs->f['n2'];
                    $n10 = $rs->f['n1'] == 0 - 1 ? "" : $rs->f['n1'];
                }
                else
                {
                    if ($_8hFlag)
                    {
                        $n8 = $rs->f['n1'] == 0 - 1 ? "" : str_pad($rs->f['n1'], 2, "0", STR_PAD_LEFT);
                        $n7 = $rs->f['n2'] == 0 - 1 ? "" : str_pad($rs->f['n2'], 2, "0", STR_PAD_LEFT);
                        $n6 = $rs->f['n3'] == 0 - 1 ? "" : str_pad($rs->f['n3'], 2, "0", STR_PAD_LEFT);
                        $n5 = $rs->f['n4'] == 0 - 1 ? "" : str_pad($rs->f['n4'], 2, "0", STR_PAD_LEFT);
                        $n4 = $rs->f['n5'] == 0 - 1 ? "" : str_pad($rs->f['n5'], 2, "0", STR_PAD_LEFT);
                        $n3 = $rs->f['n6'] == 0 - 1 ? "" : str_pad($rs->f['n6'], 2, "0", STR_PAD_LEFT);
                        $n2 = $rs->f['n7'] == 0 - 1 ? "" : str_pad($rs->f['n7'], 2, "0", STR_PAD_LEFT);
                        $n1 = $rs->f['n8'] == 0 - 1 ? "" : str_pad($rs->f['n8'], 2, "0", STR_PAD_LEFT);
                        $chkN6 = $rs->f['n6'];
                        $chkN7 = $rs->f['n7'];
                        $chkN8 = $rs->f['n8'];
                    }
                    else
                    {
                        $n1 = $rs->f['n5'] == 0 - 1 ? "" : str_pad($rs->f['n5'], 2, "0", STR_PAD_LEFT);
                        $n2 = $rs->f['n4'] == 0 - 1 ? "" : str_pad($rs->f['n4'], 2, "0", STR_PAD_LEFT);
                        $n3 = $rs->f['n3'] == 0 - 1 ? "" : str_pad($rs->f['n3'], 2, "0", STR_PAD_LEFT);
                        $n4 = $rs->f['n2'] == 0 - 1 ? "" : str_pad($rs->f['n2'], 2, "0", STR_PAD_LEFT);
                        $n5 = $rs->f['n1'] == 0 - 1 ? "" : str_pad($rs->f['n1'], 2, "0", STR_PAD_LEFT);
                    }
                }
                $classStr = "td2";
                break;
            default :
                $classStr = "td2";
                break;
        }
		if($gametype!=25 && $gametype!=26){
        	$openFlag = $MyLotto_3d->checkOpen($rs->f['n3'], $rs->f['n2'], $rs->f['n1'], $rs->f['n4'], $rs->f['n5'], $chkN6, $chkN7, $chkN8);
		}
		else
			$openFlag = $MyLotto_3d->checkOpen($rs->f['n3'], $rs->f['n2'], $rs->f['n1'], -1, -1, $chkN6, $chkN7, $chkN8);
        $list .= "<tr class=\"{$classStr}\" align=right>";
        if ($supAmdFlag)
        {
            $list .= "<td nowrap><a href=\"op.php?op=admin&fp={$lotto3dphp}&cmd=edit&gametype={$gametype}&id=" . $rs->f['id'] . "\">" . $rs->f['open'] . "</a></td>";
        }
        else if ($openFlag && $rs->f['open'] != $paperDay)
        {
            $list .= "<td nowrap>" . $rs->f['open'] . "</td>";
        }
        else if (SubAccountRight($curruser, 3) == 2)
        {
            $list .= "<td><a href=\"op.php?op=admin&fp={$lotto3dphp}&cmd=edit&gametype={$gametype}&id=" . $rs->f['id'] . "\">" . $rs->f['open'] . "</a></td>";
        }
        else
        {
            $list .= "<td nowrap>" . $rs->f['open'] . "</td>";
        }
        $dateNum = date("w", strtotime($rs->f['open']));
        $list .= "<td nowrap>" . $g_weekname[$dateNum] . "</td>";
        if ($showOpenTime)
        {
            $openbetIntTemp = strtotime($rs->f['openbet']);
            if (date("Y-m-d", $openbetIntTemp) != $rs->f['open'])
            {
                $list .= "<td nowrap class=\"td14\">";
            }
            else
            {
                $list .= "<td nowrap>";
            }
            $list .= date("H:i", $openbetIntTemp) . "</td>";
        }
        $list .= "<td nowrap>" . $rs->f['round'] . "</td>";
        if ($openFlag)
        {
            if ($gametype == 24)
            {
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n10}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n9}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n8}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n7}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n6}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n5}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n4}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n3}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n2}.png\"/></td>";
                $list .= "<td class=\"ball3dBgS2\"><img src=\"./image/pk{$n1}.png\"/></td>";
                $chkStr = "{$n10},{$n9},{$n8},{$n7},{$n6},{$n5},{$n4},{$n3},{$n2},{$n1}";
            }
			elseif ($show3D3S == 3)
			{
				$list .= ($n3==''?"<td>&nbsp;</td>":"<td align=\"center\"><img src='skin/1/img/ball/".$n3.".png' width=30></td>");
                $list .= ($n2==''?"<td>&nbsp;</td>":"<td align=\"center\"><img src='skin/1/img/ball/".$n2.".png' width=30></td>");
				$list .= ($n1==''?"<td>&nbsp;</td>":"<td align=\"center\"><img src='skin/1/img/ball/".$n1.".png' width=30></td>");
			}
            else
            {
                if ($_8hFlag)
                {
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n8 ? "3Pink" : "2" ) . "\">{$n8}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n7 ? "3Pink" : "2" ) . "\">{$n7}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n6 ? "3Pink" : "2" ) . "\">{$n6}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n5 ? "3Pink" : "2" ) . "\">{$n5}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n4 ? "3Pink" : "2" ) . "\">{$n4}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n3 ? "3Pink" : "2" ) . "\">{$n3}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n2 ? "3Pink" : "2" ) . "\">{$n2}</div></td>";
                    $list .= "<td><div  class=\"ball3dBgS" . ( 18 < $n1 ? "3Pink" : "2" ) . "\">{$n1}</div></td>";
                    $chkStr = "{$n8},{$n7},{$n6},{$n5},{$n4},{$n3},{$n2},{$n1}";
                }
                else
                {
                    $chkStr = "{$n5},{$n4},{$n3},{$n2},{$n1}";
                    if ($Show5NFlag)
                    {
                        $list .= "<td align=\"center\"><div class='ball3dBgS" . $nClrArr[$gametype][4] . "'>{$n5}</div></td>";
                        $list .= "<td align=\"center\"><div class='ball3dBgS" . $nClrArr[$gametype][3] . "'>{$n4}</div></td>";
                    }
                    else
                    {
                        $chkStr = "{$n3},{$n2},{$n1}";
                    }
                    $list .= "<td align=\"center\"><div class='ball3dBgS" . $nClrArr[$gametype][2] . "'>{$n3}</div></td>";
                    $list .= "<td align=\"center\"><div class='ball3dBgS" . $nClrArr[$gametype][1] . "'>{$n2}</div></td>";
                    $list .= "<td align=\"center\"><div class='ball3dBgS" . $nClrArr[$gametype][0] . "'>{$n1}</div></td>";
                }
            }
        }
        else
        {
            $list .= "<td colspan='{$colspanNum}'>&nbsp;</td>";
            $chkStr = "";
        }
        if ($showRound)
        {
            switch ($gametype)
            {
                case 10 :
                    $myround = date("Ymd", $openbetIntTemp) . "-" . $rs->f['round'];
                    break;
                case 11 :
                    $myround = $rs->f['round'];
                    break;
                case 12 :
                    $chkRTemp = substr($rs->f['round'], 4);
                    if ($chkRTemp != "120")
                    {
                        $myround = date("Ymd", $openbetIntTemp) . "-" . $chkRTemp;
                    }
                    else
                    {
                        $myround = date("Ymd", $openbetIntTemp - 61) . "-" . $chkRTemp;
                    }
                    break;
                case 13 :
                case 15 :
                    $myround = date("Ymd", $openbetIntTemp) . "-" . substr($rs->f['round'], 4);
                    break;
                case 14 :
                    $chkRTemp = substr($rs->f['round'], 5);
                    if (71 < $chkRTemp)
                    {
                        $myround = ( ( intval(date("Ymd", $openbetIntTemp)) - 1 ) . "-" ) . $chkRTemp;
                    }
                    else
                    {
                        $myround = date("Ymd", $openbetIntTemp) . "-" . $chkRTemp;
                    }
                    break;
                case 20 :
                case 21 :
                case 22 :
                case 23 :
                case 24 :
				case 25 :
				case 26 :
                    $myround = $rs->f['round'];
                    break;
            }
            $list .= "<td id=\"myround_{$myround}\"><span style='display:none'>{$chkStr}</span></td>";
        }
        if (strtotime($rs->f['open']) < $paperShowOpenInt)
        {
            if (0 < $rs->f['amount'])
            {
                $list .= "<td nowrap>0</td>";
            }
            else
            {
                if ($rs->f['open'] != $today2)
                {
                    $myx = "x";
                }
                else
                {
                    $myx = "";
                }
                $amountRs = getdb("SELECT sum(amount) FROM {$myx}bet_{$tbl} WHERE lotto_id =" . $rs->f['id'] . " AND rame IN (0,9)");
                if (!$amountRs->eof && 0 < $amountRs->f[0])
                {
                    $list .= "<td nowrap>" . intval($amountRs->f[0]) . "</td>";
                }
                else
                {
                    $list .= "<td nowrap>0</td>";
                }
            }
            $list .= "<td nowrap>" . say_numbercolor(0, 2) . "</td>";
            $list .= "<td nowrap>" . say_numbercolor(0, 2) . "</td>";
            $list .= "<td nowrap>0</td>";
            $list .= "<td nowrap>" . say_numbercolor(0, 2) . "</td>";
            $list .= "<td nowrap>" . say_numbercolor(0, 2) . "</td>";
        }
        else
        {
            if (0 < $rs->f['amount'] && $curruser['account'] == G_SUPERACCOUNT && $curruser['acl'] == 255)
            {
                $betlistUrl = "op.php?op=agent&fp=betlist_3d&num=all&dates=" . $rs->f['open'] . "&datee=" . $rs->f['open'] . "&backpage=1&gametype={$gametype}&lid=" . $rs->f['id'];
                $list .= "<td nowrap><a href=\"{$betlistUrl}\">" . $rs->f['amount'] . "</a></td>";
            }
            else
            {
                if ($rs->f['open'] != $today2)
                {
                    $myx = "x";
                }
                else
                {
                    $myx = "";
                }
                $amountRs = getdb("SELECT sum(amount) FROM {$myx}bet_{$tbl} WHERE lotto_id =" . $rs->f['id'] . " AND rame IN (0,9)");
                if (!$amountRs->eof && 0 < $amountRs->f[0])
                {
                    $betlistUrl = "op.php?op=agent&fp=betlist_3d&num=all&dates=" . $rs->f['open'] . "&datee=" . $rs->f['open'] . "&backpage=1&gametype={$gametype}&lid=" . $rs->f['id'];
                    $list .= "<td nowrap><a href=\"{$betlistUrl}\">" . intval($amountRs->f[0]) . "</a></td>";
                }
                else
                {
                    $list .= "<td nowrap>" . intval($rs->f['amount']) . "</td>";
                }
            }
            $list .= "<td nowrap>" . say_numbercolor($rs->f['mb'], 2) . "</td>";
            $list .= "<td nowrap>" . say_numbercolor($rs->f['ad'], 2) . "</td>";
            if (0 < $rs->f['ua'] && $curruser['account'] == G_SUPERACCOUNT && $curruser['acl'] == 255)
            {
                $betlistUrl = "op.php?op=admin&fp=bet8list_3d&num=all&dates=" . $rs->f['open'] . "&datee=" . $rs->f['open'] . "&backpage=1&gametype={$gametype}";
                $list .= "<td nowrap><a href=\"{$betlistUrl}\">" . intval($rs->f['ua']) . "</a></td>";
            }
            else if ($rs->f['open'] == $today2)
            {
                $amountRs = getdb("SELECT sum(amount) FROM bet8_{$tbl} WHERE lotto_id =" . $rs->f['id'] . " AND rame IN (0,9)");
                if (!$amountRs->eof && 0 < $amountRs->f[0])
                {
                    $betlistUrl = "op.php?op=admin&fp=bet8list_3d&num=all&dates=" . $rs->f['open'] . "&datee=" . $rs->f['open'] . "&backpage=1&gametype={$gametype}";
                    $list .= "<td nowrap><a href=\"{$betlistUrl}\">" . intval($amountRs->f[0]) . "</a></td>";
                }
                $list .= "<td nowrap>0</td>";
            }
            else
            {
                $list .= "<td nowrap>" . intval($rs->f['ua']) . "</td>";
            }
            $list .= "<td nowrap>" . say_numbercolor($rs->f['ur'], 2) . "</td>";
            $list .= "<td nowrap>" . say_numbercolor($rs->f['rsum'], 2) . "</td>";
        }
        if ($showRateFlag)
        {
            if (date("Y-m") <= substr($rs->f['open'], 0, 7))
            {
                $list .= "<td nowrap><a href=\"op.php?op=admin&fp=rate{$showPg}&gametype={$gametype}&id=" . $rs->f['id'] . "\">赔率</a></td>";
            }
            else
            {
                $list .= "<td nowrap>&#12288;&#12288;</td>";
            }
        }
        $_okMsg = empty($rs->f['note']) ? "" : "_ok";
        $state = $rs->f['state'];
        $stateMsg = $stateArr[$state];
        $list .= "<td nowrap>{$stateMsg}<a href=\"#" . $rs->f['id'] . "_" . $rs->f['round'] . "\" class=\"editNote\" ><img src=\"image/edit{$_okMsg}.png\" width=\"16\" border=\"0\"></a></td>";
        $list .= "</tr>";
        $totalamount += $rs->f['amount'];
        $totalmb += $rs->f['mb'];
        $totalad += $rs->f['ad'];
        $totalua += $rs->f['ua'];
        $totalur += $rs->f['ur'];
        $totalrsum += $rs->f['rsum'];
        $rs->movenext();
    }
    $list .= "</tbody>";
    $list .= "<tr class=\"bgClc_{$gametype} ballamount\">";
    $list .= "<td colspan=\"{$colspan}\" align=right>总计</td>";
    $list .= "<td nowrap>" . $totalamount . "</td>";
    $list .= "<td nowrap>" . say_numbercolor($totalmb, 2) . "</td>";
    $list .= "<td nowrap>" . say_numbercolor($totalad, 2) . "</td>";
    $list .= "<td nowrap>" . intval($totalua) . "</td>";
    $list .= "<td nowrap>" . say_numbercolor($totalur, 2) . "</td>";
    $list .= "<td nowrap>" . say_numbercolor($totalrsum, 2) . "</td>";
    if ($showRateFlag)
    {
        $list .= "<td nowrap>&nbsp;</td>";
    }
    $list .= "<td nowrap>&nbsp;</td>";
    $list .= "</tr>";
}
$tpl->set(array ("list" => $list, "button" => $rs->pagelink(), "width" => $width, "myTitle" => $tblName, "gametype" => $gametype, "tdN5" => $tdN5, "colspanNum" => $colspanNum, "colspanAllTr" => $colspanAllTr));
if ($showRateFlag)
{
    $tpl->set(array ("td1" => "<td nowrap rowspan='2'>赔率</td><td nowrap rowspan='2'>备注</td>", "updivSave" => "<input type=\"button\" value=\"储存\" id=\"updivSave\" />"));
}
else
{
    $tpl->set("td1", "<td nowrap rowspan='2'>备注</td>");
}
if ($showOpenTime)
{
    $tpl->set(array ("showOpenTimeTd" => "<td rowspan='2'>开奖<br />时间</td>", "showOpenTimeTd02" => "<td rowspan='2'>&nbsp;</td>", "note3s" => "<div>※开奖时间背景颜色为<span class=\"td14\">粉红色</span>时，代表已过凌晨</div>"));
}
$tpl->load("main", "history_3d.htm");
$ui->header();
if ($showRateFlag)
{
    $menustradd = "{$editpapadate}<a href=op.php?op=admin&fp={$lotto3dphp}&cmd=add&gametype={$gametype}>新增</a>";
}
else
{
    $menustradd = "";
}
$theDayCounts = 0;
$theDayCountRs = getdb("SELECT count(*) FROM lotto_{$tbl} WHERE open ='{$paperDay}'");
if (!$theDayCountRs->eof)
{
    $theDayCounts = $theDayCountRs->f[0];
}
echo title("{$tblName} 开奖管理: 本日 {$paperDay} 开盘期数共({$theDayCounts})期", $menustradd, $width);
echo "<br />";
$tpl->show("main");
if (isset($historyGetNum_3d))
{
    $tpl->show("historyGetNum_3d");
}
$ui->footer();